﻿using HslCommunication.Core.Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Net_SCADA
{
    class fdMessage
    {

        private static int msgIndex = 0;
        /// <summary>
        /// 根据内容显示提示窗口
        /// </summary>
        /// <param name="_Index">带入的请求索引</param>
        public static DialogResult ShowMsg(string content, string title, int btns,int index,string subContentLeft="",string subContentRight="")
        {
            msgIndex = index;
            netForms.fmMsgBox = new Form_MessageBox(title, content, btns,subContentLeft,subContentRight);
            DialogResult res= netForms.fmMsgBox.ShowDialog();
            return res;
        }
        //显示一个信息类对象的内容
        public static DialogResult ShowMsg(MessageInfo msgInfo, string subContntRight, int languageIndex)
        {
           return  ShowMsg(msgInfo.msgContent[languageIndex], msgInfo.msgTitle[languageIndex], msgInfo.msgButtons, msgInfo.msgIndex, msgInfo.subContent[languageIndex], subContntRight);
        }
        //显示既定的提示信息
        public static DialogResult ShowMsg(int msgInfoIndex, string subContntRight, int languageIndex)
        {
            return ShowMsg(MultipleLanguage.messageInfos[msgInfoIndex], subContntRight, languageIndex);
        }
        /// <summary>
        /// 处理信息窗口返回的按钮信息
        /// </summary>
        public static void DealMessage(int _callBack)
        {
            if (netForms.fmMsgBox != null)
            {
                netForms.fmMsgBox.Dispose();
                netForms.fmMsgBox = null;
            }
            switch (_callBack)
            {
                case 1://ok
                    switch (msgIndex)
                    {
                        case 1:
                            break;
                        case 2://删除工艺
                            netForms.fmDesign.DeleteProductProgram();
                            break;
                        case 3://创建工艺
                         //   netForms.fmDesign.Createpro();
                            break;
                        case 4://结束批次
                            netForms.fmRun.StopBatch();
                            break;
                        case 99:
                            Application.Exit();
                            break;
                        default:
                            break;
                    }
                    break;
                case 2://cancel
                    break;
                default:
                    break;
            }
        }
    }

    public class MessageInfo
    {
        //默认暂时先搞五个语言
        public string[] msgTitle { get; set; } = new string[5] { "", "", "", "", "" };//多语言  ="中文;Engli;或新闻".Split(';');
        public string[] msgContent { get; set; } = new string[5] { "", "", "", "", "" };//多语言  ="中文;Engli;或新闻".Split(';');
        public string[] subContent { get; set; } = new string[5] { "", "", "", "", "" };//附加标题，用以显示变量信息。
        public int msgButtons { get; set; } = 1;//显示的按钮的数量0=0个 1=确认  2=确认+取消
        public int msgIndex { get; set; } = 0;//用来处理信息的内容，默认不处理事件
    }
}
